package com.example.demo.service;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class IdService {
    @Autowired
    private final SnowflakeIdGenerator idGenerator;

    @Autowired
    public IdService(SnowflakeIdGenerator idGenerator) {
        this.idGenerator = idGenerator;
    }
    private static final Logger logger = LoggerFactory.getLogger(IdService.class);

    public long generateId() {
        long newId = idGenerator.nextId56();
        logger.info("Generated ID: {}", newId);
        return newId;
    }
}
